package pers.cz.chat.constants;

import java.util.HashSet;
import java.util.Set;

/**
 * @program: Jef-Chat
 * @description: 指令枚举
 * @author: Cheng Zhi
 * @create: 2025-01-30 21:36
 **/
public enum Commands {
    HELP("-help", "帮助"),
    REGIST("-regist", "注册"),
    LOGIN("-login", "登录"),
    SHOW("-show", "展示当前在线用户"),
    CONN("-conn", "连接某个用户或者某个群组，forexample: -conn xxx"),
    CREATEGROUP("-creategroup", "创建群聊"),
    CLEAR("-clear", "清屏"),
    EXIT("-exit", "退出");

    private String command;
    private String desc;

    private static final Set<String> COMMAND_SET = new HashSet<>();

    static {
        for (Commands value : Commands.values()) {
            COMMAND_SET.add(value.command);
        }
    }

    Commands(String command, String desc) {
        this.command = command;
        this.desc = desc;
    }

    public String getCommand() {
        return this.command;
    }

    public String getDesc() {
        return this.desc;
    }

    public static boolean contains(String command) {

       if (command == null || command.trim().isEmpty()) {
           return false;
       }

       return COMMAND_SET.contains(command.trim());
    }
}
